package com.pt25.base.model.websocket.handler;

import com.pt25.base.model.websocket.WebsocketHandler;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

@Slf4j
@Component
@ChannelHandler.Sharable
public class TextMessageHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
    @Resource
    private WebsocketHandler websocketHandler;
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame) throws Exception {
        websocketHandler.handleTextMessage(channelHandlerContext, textWebSocketFrame);
    }
}
